package com.fz.controller;

import com.fz.entity.College;
import com.fz.mapper.AdminArtistMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by Z-C-Y on 2018-03-08.
 * artist.jsp===艺术家 后台管理
 */
@Controller
public class AdminArtistController {
    @Autowired
    protected AdminArtistMapper adminArtistMapper;

    /*艺术家  hartistype.jsp*/
    @RequestMapping("/admin/hartistype")
    public String hartist(Model model, HttpServletRequest request) {
        /*根据id进行删除*/
        if (request.getParameter("deleteID") != null && !"".equals(request.getParameter("deleteID"))) {
            int deleteID = Integer.parseInt(request.getParameter("deleteID"));
            adminArtistMapper.deleteCollege(deleteID);
        }

        /*添加字段*/
        if (request.getParameter("add") != null && !"".equals(request.getParameter("add"))) {
            String add = request.getParameter("add");
            adminArtistMapper.addCollege(add);
        }

        /*拿到-艺术家--查询条件--毕业美院*/
        List<College> listCollege = adminArtistMapper.queryCollege();
        model.addAttribute("listCollege", listCollege);
        return "/admin/hartistype";

    }




}
